﻿<xsl:stylesheet version="1.0"
	xmlns:date="http://exslt.org/dates-and-times"
	xmlns:set="http://exslt.org/sets"  xmlns:ebe="http://cks/ebemethods"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="date set ebe">

	<xsl:param name="IsBlogOwner" />
	<xsl:param name="RelativeUrl" />

	<xsl:output omit-xml-declaration="yes" />
	<xsl:key match="rows/row" use="substring(PublishedDate, 0, 8)" name="months" />

	<xsl:template match="/">
		<ul>
			<xsl:apply-templates select="rows/row[generate-id(.) = generate-id(key('months', substring(PublishedDate, 0, 8)))]" />
		</ul>
	</xsl:template>

	<xsl:template match="row">
		
		<xsl:variable name="publishedDate" select="date:parseDate(PublishedDate, 'yyyy-MM-dd HH:mm:ss')"/>
		<xsl:variable name="postCount" select="count(key('months',substring(PublishedDate, 0, 8)))"/>

		<li>
			<a title="{Title}" href="{ebe:createMonthUrl(PublishedDate)}">
				<xsl:value-of select="date:format-date($publishedDate, 'MMMM yyyy')"/> 
			</a> (<xsl:value-of select="$postCount"/>)
		</li>			
	</xsl:template>

</xsl:stylesheet>
